home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 January / enter-2004-01.iso / files / maxima-5.9.0.exe / {app} / libexec / maxima / 5.9.0 / mgnuplot < prev    next >
Encoding:
Text File  |  2003-02-09  |  2.7 KB  |  116 lines

  1. #!/bin/sh
  2. # comment \
  3. exec wish "$0" "$@"
  4.  
  5.  
  6. #set gnuPlotstream [open {|  gnuplot /d19/staff/wfs/tmp/jo } w]
  7. set gnuPlotstream [open {|  gnuplot  } r+]
  8.  
  9.  
  10. proc sendgnu com {
  11.     global gnuPlotstream
  12.     puts stdout $com ; flush stdout
  13.     puts $gnuPlotstream $com ; flush $gnuPlotstream
  14. }
  15.  
  16. set ii 0
  17. while {$ii < $argc} {
  18.  switch -exact "X[lindex $argv $ii]"  {
  19.     X-parametric3d {
  20.     sendgnu "set parametric\n" 
  21.     sendgnu "set data style lines\n"
  22.     sendgnu "set hidden\n"
  23.     set ii [expr {$ii + 1}]
  24.     sendgnu "splot '[lindex $argv $ii]'\n" }
  25.     X-plot2d {
  26.     set ii [expr {$ii + 1}]
  27.     sendgnu "set data style lines"
  28.     sendgnu "plot '[lindex $argv $ii]'\n" 
  29.     }
  30.     X-title {
  31.     set ii [expr {$ii + 1}]
  32.     sendgnu "set title '[lindex $argv $ii]'\n" }
  33.     
  34.     }
  35.     set ii [expr {$ii +1}]
  36.     }
  37.       
  38. set xrot 60
  39. set zrot 30
  40.  
  41.  
  42. text .text
  43. .text configure -height 4 -width 40
  44.  
  45. proc getoptions {} {
  46. #    unlink gnu-optionsxx
  47.     set tmp gnu-optionsxx
  48.     exec rm -f $tmp
  49.     sendgnu "save '$tmp'\n"
  50.     while {[file exists $tmp] <= 0} {exec sleep 0}
  51.     set at [.fra.options nearest 0]
  52.     set f [ open gnu-optionsxx ]
  53.     .fra.options delete 0 end
  54.     while { [gets $f line] >= 0 } {
  55.     .fra.options insert end [lrange $line 0 end ]}
  56.     .fra.options yview $at    
  57.     }
  58.  
  59. frame .fra -bd 2
  60. label .fra.label -text "Current Set Options"
  61. scrollbar .fra.scroll -command ".fra.options yview"    
  62. listbox .fra.options -yscrollcommand ".fra.scroll set" -relief sunken -bd 2
  63. pack .fra.label
  64. pack .fra.options -side left
  65. pack .fra.scroll -side right -fill y
  66. bind .fra.options <Double-1> "set selected_option  \[lindex \[selection get\] 0\]"
  67. frame .option_edit
  68.  
  69. proc msg a {global $a
  70.  sendgnu [format "%s\n\nreplot\n" [expr $$a]] ;
  71.  set $a ""
  72.  getoptions}
  73.  
  74. proc mkOption_edit {a b} {
  75.     global $b
  76.    label $a.label -text "Edit: "
  77.    entry $a.entry -width 20 -relief sunken -bd 2 -textvariable $b
  78.     bind $a.entry  <Return> "msg  $b"
  79.    pack $a.label $a.entry -side left -padx 1m -pady 2m
  80. }
  81.  
  82. mkOption_edit .option_edit selected_option
  83.  
  84.  
  85. getoptions
  86.  
  87. button .exit -text "Exit" -command {
  88.     sendgnu  "exit\n"
  89.     destroy .
  90. }
  91.  
  92. button .save -text "save gnuplot.out" -command {
  93.     sendgnu "save 'gnuplot.out'\n"
  94.  }
  95.  
  96. scale .rotxscale -label "xrotation"  \
  97.    -orient horizontal -length 200 -from 0 -to 180 \
  98.     -command gnuPlotsetview -tickinterval 60
  99. scale .rotzscale -label "zrotation" \
  100.     -orient horizontal -length 200 -from 0 -to 360 \
  101.     -command gnuPlotsetview -tickinterval 120
  102.  
  103. set initted 0
  104. .rotxscale set $xrot
  105. .rotzscale set $zrot
  106.  
  107. proc gnuPlotsetview value  {
  108.     global initted
  109.     if { $initted < 2 } { set initted [expr {$initted + 1}]} \
  110.     else \
  111.     {sendgnu [format "set view %d,%d\nreplot\n" [.rotxscale get] [.rotzscale get]]}}
  112.  
  113. pack .exit   .rotxscale .rotzscale .fra .option_edit .save
  114.  
  115.  
  116.